package com.zha;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class writeExcel {
    public static void main(String[] args) throws IOException {
        //创建工作簿
        HSSFWorkbook workbook = new HSSFWorkbook();
        //创建工作表
        HSSFSheet sheet = workbook.createSheet("sheet1");
        for (int row = 0; row < 10; row++){
            HSSFRow rows = sheet.createRow(row);
            for (int col = 0; col < 10; col++) {
                //向工作表中添加内容
                rows.createCell(col).setCellValue("data"+ row + col);
            }
        }
        File xlsFile = new File("f:/all.student");
        FileOutputStream xlsStram = new FileOutputStream(xlsFile);
        workbook.write(xlsStram);
    }
}
